#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct man
{
	char name[10];
	int age;
}student;
typedef struct jie
{
	student stu;
	int i;
	struct jie * next;
}dian;
dian * init()
{
	dian * a;
	a=(dian *)malloc(sizeof(dian));
	student x;
	x .age =0;
	char name[10]={0};
	strcpy(x.name ,name);
	a->stu =x;
	a->i =0;
	a->next =a;
	return a;
}
dian * locate(dian * p,int i)
{
	dian * a=p;
	if(i==0)
	{
		return a;
	}
	else
	{
		do
		{
			a=a->next ;
		}while(a->i !=i&&a->i !=0);
		return a;
	}
}
void cha(dian * p,int i,student x)
{
	dian * a=NULL;
	a=locate(p,i-1);
	dian * b=NULL;
	b=init();
	b->i =i;
	b->stu =x;
	dian * t=a->next ;
	a->next =b;
	b->next =t;
	a=b->next ;
	while(a->i !=0)
	{
		a->i ++;
		a=a->next ;
	}
}
void put(dian * p,int i)
{
	dian * a=p;
	if(i)
	{
		a=locate(p,i);
		printf("number %d name:%s age:%d\n",a->i ,a->stu .name ,a->stu .age );
	}
	else
	{
		if(p->next ==p)
		{
			printf("nothing\n");
		}
		else
		{
			a=locate(p,1);
			while(a->i !=0)
			{
				printf("number %d name:%s age:%d\n",a->i ,a->stu .name ,a->stu .age );
				a=a->next ;
			}
		}
	}
}
void gai(dian * p,int i,student x)
{
	dian * a=NULL;
	a=locate(p,i);
	a->stu =x;
}
void shan(dian * p,int i)
{
	dian * a=NULL;
	a=locate(p,i-1);
	dian * b=NULL;
	b=a->next ;
	a->next =b->next ;
	free(b);
	b=a->next ;
	while(b->i !=0)
	{
		b->i --;
		b=b->next ;
	}
}
void main()
{
	char c;
	int i;
	char name[10];
	int age;
	student x;
	dian * p=NULL;
	p=init();
	do
	{
		scanf("%c",&c);
		switch(c)
		{
		case'i':
			{
				scanf("%d%s%d",&i,&name,&age);
				strcpy(x.name ,name);
				x.age =age;
				cha(p,i,x);
				put(p,0);
				break;
			}
		case'd':
			{
				scanf("%d",&i);
				shan(p,i);
				put(p,0);
				break;
			}
		case'u':
			{
				scanf("%d%s%d",&i,&name,&age);
				strcpy(x.name ,name);
				x.age =age;
				gai(p,i,x);
				put(p,0);
				break;
			}
		case'r':
			{
				scanf("%d",&i);
				put(p,i);
				break;
			}
		case'q':
			{
				exit(0);
			}
		}
	}while(1);
}